<template>
	<view>
		<image src="../../../客服微信.jpg"></image>
	</view>
</template>

<script>
	import { register,sendSmsCode } from '@/common/http.api.js';
	export default {
		data() {
			return {
				code: '',
				mobile: '',
				password: '',
				protocol:'',
				sending: false,
				sendTime: '',
				count: 60,
				agreeList: [
					{
						name: '',
						checked: false,
						disabled: false
					},
				],
				mobileText:'',
				fillmobileText:'',
				fillcaptchaText:'',
				passwordText:'',
				fillpasswordText:'',
				signupnowText:'',
				privacyText:'',
				protocolText:'',
				andText:'',
				fillmobileruleText:'',
				fillcorrectmobileruleText:'',
				sendcodeText:'',
				sendsuccessText:'',
				senderrorText:'',
				minutegetText:'',
				refetchsecondsText:'',
				pleaseenteraccountText:'',
				pleasepasswordText:'',
				passworderrorText:'',
				agreeagreementText:'',
			}
		},
		onShow(){
			this.refresh();
		},
		methods: {
			refresh(){
				this.mobileText = this.$t('register.mobile.text');
				this.fillmobileText = this.$t('register.fillmobile.text');
				this.captchaText = this.$t('register.captcha.text');
				this.sendTime = this.$t('register.getcaptcha.text');
				this.fillcaptchaText = this.$t('register.fillcaptcha.text');
				this.passwordText = this.$t('register.password.text');
				this.fillpasswordText = this.$t('register.fillpassword.text');
				this.signupnowText = this.$t('register.signupnow.text');
				this.privacyText = this.$t('register.privacy.text');
				this.protocolText = this.$t('register.protocol.text');
				this.agreeList[0].name = this.$t('register.agree.text');
				this.andText = this.$t('register.and.text');
				
				this.fillmobileruleText = this.$t('register.fillmobilerule.text');
				this.fillcorrectmobileruleText = this.$t('register.fillcorrectmobilerule.text');
				this.sendcodeText = this.$t('register.sendcode.text');
				this.sendsuccessText = this.$t('register.sendsuccess.text');
				this.senderrorText = this.$t('register.senderror.text');
				this.minutegetText = this.$t('register.minuteget.text');
				this.refetchsecondsText = this.$t('register.refetchseconds.text');
				this.pleaseenteraccountText = this.$t('register.pleaseenteraccount.text');
				this.pleasepasswordText = this.$t('register.pleasepassword.text');
				this.passworderrorText = this.$t('register.passworderror.text');
				this.agreeagreementText = this.$t('register.agreeagreement.text');
			},
			isAgreeChange() {
				//是否选择协议
				this.agreeList[0].checked = !this.agreeList[0].checked;
				if(!this.agreeList[0].checked){
					this.protocol = '';
				}else{
					this.protocol = 'checked';
				}
			},
			//获取验证码
			sendCode() {
				let taht = this;
				const {
					mobile
				} = this;
				if (!mobile) {
					this.$refs.uToast.show({
						message: taht.fillmobileruleText,
						type: 'error',
					})
				} else if (mobile.length !== 11) {
					this.$refs.uToast.show({
						message: taht.fillcorrectmobileruleText,
						type: 'error',
					})
				} else {
					this.$refs.uToast.show({
						message: taht.sendcodeText,
						type: 'loading',
					})
					sendSmsCode({
						mobile: this.mobile,
						scene:1
					})
					.then(res => {
						debugger
						if (res.code === 0) {
							this.sending = true;
							this.$refs.uToast.show({
								message: taht.sendsuccessText,
								type: 'success',
							})
							this.countDown();
							uni.hideLoading();
						} else {
							uni.hideLoading();
							uni.showModal({
								showCancel: false,
								title: taht.senderrorText,
								content: res.msg ? res.msg : taht.minutegetText,
							});
						}
					});
				}
			},
			countDown() {
				let that = this;
				const {
					count
				} = this;
				if (count === 1) {
					this.count = 60;
					this.sending = false;
					this.sendTime = that.$t('register.getcaptcha.text');
				} else {
					this.count = count - 1;
					this.sending = true;
					this.sendTime = count - 1 + that.refetchsecondsText;
					setTimeout(this.countDown.bind(this), 1000);
				}
			},
			inputChange(e) {
				const key = e.currentTarget.dataset.key;
				this[key] = e.detail.value;
			},
			navBack() {
				uni.navigateBack();
			},
			navTo(url) {
				uni.navigateTo({
					url
				})
			},
			toLogin() {
				let that = this;
				const {
					mobile,
					password,
					code,
					showAgree = this.agreeList[0].checked
				} = this;
				if (!mobile) {
					this.$refs.uToast.show({
						message: that.pleaseenteraccountText,
						type: 'error',
					})
				} else if (!password) {
					this.$refs.uToast.show({
						message: that.pleasepasswordText,
						type: 'error',
					})
				} else if (password.length < 8) {
					this.$refs.uToast.show({
						message: that.passworderrorText,
						type: 'error',
					})
				} else if (!showAgree) {
					this.$refs.uToast.show({
						message: that.agreeagreementText,
						type: 'error',
					})
				} else {
					this.logining = true;
					uni.navigateTo({
						url: 'pages/common/public/complete?password='+this.password+'&mobile='+this.mobile+'&code='+this.code
					});
				}
			},
		},

	}
</script>

<style lang='scss'>
	page {
		background: #fff;
	}
	.logo {
		width: 260rpx;
		height: 260rpx;
		border-radius: 50%;
		margin: 10rpx auto 20rpx auto;
	}
	
	.logo image {
		width: 260rpx;
		height: 260rpx;
		border-radius: 50%;
	}
    .cu-form-group{
		background-color: #ffffff;
		padding: 1px 15px;
		display: flex;
		align-items: center;
		min-height: 51px;
		justify-content: space-between;
	}
	.cu-form-group .title {
	    text-align: justify;
	    padding-right: 15px;
	    font-size: 15px;
	    position: relative;
	    height: 30px;
	    line-height: 30px;
	}
	.cu-form-group uni-input {
	    flex: 1;
	    font-size: 15px;
	    color: #555;
	    padding-right: 10px;
	}
	
	.footer {
		justify-content: center;
		margin-top: 32upx;
		text-align: center;
		display: flex;
	}

	.send-msg {
		border-radius: 30px;
		color: white;
		height: 30px;
		font-size: 14px;
		line-height: 30px;
		background: #e10a07;
	}

	.send-msgs {
		border-radius: 30px;
		color: black;
		height: 30px;
		font-size: 14px;
		line-height: 30px;
		background: white;
	}

	.container {
		padding-top: 50px;
		position: relative;
		width: 100%;
		height: 100%;
		overflow: hidden;
		background: #fff;
	}

	.wrapper {
		position: relative;
		z-index: 90;
		background: #fff;
		padding-bottom: 20px;
	}

	.back-btn {
		position: absolute;
		left: 20px;
		z-index: 9999;
		padding-top: var(--status-bar-height);
		top: 20px;
		font-size: 20px;
		color: #303133;
	}

	.left-top-sign {
		font-size: 80px;
		color: #f8f8f8;
		position: relative;
	}

	.right-top-sign {
		position: absolute;
		top: 40px;
		right: -15px;
		z-index: 95;

		&:before,
		&:after {
			display: block;
			content: "";
			width: 20px;
			height: 40px;
			background: -moz-linear-gradient(left, #fa4dbe 0, #fbaa58 100%);
			background: -webkit-gradient(linear,
				left top,
				left right,
				color-stop(0, #fa4dbe),
				color-stop(100%, #fbaa58));
			background: -webkit-linear-gradient(left, #fa4dbe 0, #fbaa58 100%);
			background: -o-linear-gradient(left, #fa4dbe 0, #fbaa58 100%);
			background: -ms-linear-gradient(left, #fa4dbe 0, #fbaa58 100%);
			background: linear-gradient(to left, #fa4dbe 0, #fbaa58 100%);
		}

		&:before {
			transform: rotate(50deg);
			border-radius: 0 50px 0 0;
		}

		&:after {
			position: absolute;
			right: -198px;
			top: 0;
			transform: rotate(-50deg);
			border-radius: 50px 0 0 0;
			/* background: pink; */
		}
	}

	.left-bottom-sign {
		position: absolute;
		left: -270px;
		bottom: -320px;
		/*border: 100upx solid #d0d1fd;*/
		border-radius: 50%;
		padding: 90px;
	}


	.welcome {
		position: relative;
		left: 30px;
		top: -55px;
		font-size: 28px;
		color: #555;
		text-shadow: 1px 0px 1px rgba(0, 0, 0, .3);
	}

	.input-content {
		padding: 0 20px;
	}

	.input-item {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: center;
		padding: 0 30px;
		background: #f8f6fc;
		height: 64px;
		border-radius: 4px;
		margin-bottom: 30px;

		&:last-child {
			margin-bottom: 0;
		}

		.tit {
			height: 30px;
			line-height: 28px;
			font-size: 26upx;
			color: #606266;
		}

		input {
			height: 40px;
			font-size: 30upx;
			color: #303133;
			width: 100%;
		}
	}

	.confirm-btn {
		width: 300px;
		height: 42px;
		line-height: 42px;
		border-radius: 30px;
		margin-top: 40px;
		background: #e10a07;
		color: #fff;
		font-size: 32upx;

		&:after {
			border-radius: 60px;
		}
	}

	.confirm-btn1 {
		width: 300px;
		height: 42px;
		line-height: 42px;
		border-radius: 30px;
		margin-top: 40px;
		background: whitesmoke;
		color: grey;
		font-size: 32upx;

		&:after {
			border-radius: 60px;
		}
	}

	.forget-section {
		font-size: 26upx;
		color: #4399fc;
		text-align: center;
		margin-top: 40px;
	}

	.register-section {
		position: fixed;
		left: 0;
		bottom: 30px;
		width: 100%;
		font-size: 26upx;
		color: #606266;
		text-align: center;

		text {
			color: #4399fc;
			margin-left: 10px;
		}
	}
</style>
